#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>

#include <unistd.h>
#include <time.h>

#include <pwd.h>
#include <shadow.h>
#include <grp.h>
#include <sys/utsname.h>
#include <sys/time.h>

struct passwd* getpwnam(const char *name) {
	struct passwd *ptr;

	setpwent();
	while ((ptr=getpwent()) != NULL) {
		if (strcmp(name, ptr->pw_name) == 0)
			break;
	}
	endpwent();
	return ptr;
}

int main(int argc, char const *argv[])
{
	struct passwd* ptr = getpwnam("windy");
	printf("%s / %s / %s %s %d %d\n",\
			 ptr->pw_name, ptr->pw_gecos, ptr->pw_passwd, ptr->pw_dir, \
			 ptr->pw_shell, ptr->pw_uid, ptr->pw_gid);

	struct utsname name;
	uname(&name);
	printf("%s\n%s\n%s\n%s\n%s\n", \
		name.sysname, name.nodename, \
		name.release, name.version, name.machine);

	time_t t;
	time(&t);
	printf("%ld\n", t);
	struct timeval tv;
	gettimeofday(&tv, NULL);
	struct tm* ti;
	ti = gmtime(&t);
	printf("asc: %s\nutc: %s\n", asctime(ti), ctime(&t));

	char tbuf[1024] = {0};
	strftime(tbuf, 1024, "%c %Z", ti);
	printf("%s\n", tbuf);

	return 0;
}
